package cn.gov.customs.h2018.service.impl;

import cn.gov.customs.h2018.pojo.Article;
import cn.gov.customs.h2018.service.AsyncQuery;
import cn.gov.customs.h2018.service.ParallelQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.concurrent.CompletableFuture;

@Service("AsyncQueryImpl")
@Slf4j
public class AsyncQueryImpl implements AsyncQuery {

    @Async
    @Override
    public CompletableFuture<Article> getArticle(String id) {

        try {
            log.info(Thread.currentThread().getName());
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Article a = new Article();
        a.setId(id);
        a.setAuthorid("A:"+id);
        return CompletableFuture.completedFuture(a);
    }
}
